var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
//引入获得地址的js文件
var qqmapsdk;
const app=getApp()


Page({

  /**
   * 页面的初始数据
   */
  data: {
    question:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  //获取反馈内容
  getQuestion(e){
    console.log(e.detail.value)
    this.setData({
      question:e.detail.value
    });
  },

  //显示日期在页面上  yyy-MM-dd
  getTime(){
	  var now = new Date();
	  var year = now.getFullYear(); //得到年份
	  var month = now.getMonth();//得到月份
	  var date = now.getDate();//得到日期
	  var day = now.getDay();//得到周几
	  var hour = now.getHours();//得到小时
	  var minu = now.getMinutes();//得到分钟
	  var sec = now.getSeconds();//得到秒
	  month = month + 1;
	  if (month < 10) month = "0" + month;
	  if (date < 10) date = "0" + date;
	  if (hour < 10) hour = "0" + hour;
	  if (minu < 10) minu = "0" + minu;
	  if (sec < 10) sec = "0" + sec;
	  var time = "";
	  //精确到天
		time = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
    // return time;
    console.log(time)
    return time
},
 // 提交
 addBtn(){
  if(!this.data.question){
    wx.showModal({
      title: '提示',
      content:"请输入反馈内容！",
      showCancel:false,
      success:()=>{
        return
      }
    })
  }else{
    wx.showLoading({
      title: '请稍后...',
    })
    wx.request({ 
      url: 'http://127.0.0.1:5000/addFankui', 
      method:"POST",
      data: {
        question:this.data.question,
        tel:wx.getStorageSync('tel'),
        shijian:this.getTime()
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success:(res)=> {
        console.log(res.data)
        wx.hideLoading()
        if(res.data.code==200){
          wx.hideLoading()
          wx.showModal({
            title: '提示',
            content: "发布成功！",
            showCancel:false,
            success:()=> {
              // wx.navigateBack({
              //   delta:1
              // })
              this.setData({
                question:""
              });
            }
          })
        }else{
          wx.showModal({
            title: '提示',
            content: "发布失败！",
            showCancel:false,
            success () {
              
            }
          })
        }
      }
    })
  }
 },


})